package com.atguigu.partition2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class FlowDriver {
    public static void main(String[] args) throws Exception {

        Job job = Job.getInstance(new Configuration());

        /*
            思考？ ReduceTask的数量和分区的数量之间的关系？
                    默认 ：ReduceTask的数量 = 分区的数量
                    ReduceTask的数量 < 分区的数量 : 会报错
                    ReduceTask的数量 > 分区的数量 ：可以但是会浪费资源
         */
        //设置ReduceTask的数量
        job.setNumReduceTasks(6);
        //设置使用自定义分区类
        job.setPartitionerClass(MyPartitioner.class);

        job.setMapperClass(FlowMapper.class);
        job.setReducerClass(FlowReducer.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(FlowBean.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);
        FileInputFormat.setInputPaths(job,new Path("D:\\io\\input2"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\io\\output33333"));


        job.waitForCompletion(true);
    }
}
